# -*- coding: utf-8 -*-
# @Time:2021/07/06 22:35
# @Author:Cindy


# save this as app.py
from flask import Flask, escape, request, session

app = Flask(__name__)
app.secret_key = 'randomkey'


@app.route('/')
def hello():
    app.logger.warning('success')
    name = request.args.get("name", "World")
    return f'Hello, {escape(name)}!'


@app.route('/login', methods=['get', 'post'])
def login():
    res = {
        'method': request.method,
        'url': request.path,
        'args': request.args,
        'form': request.form
    }
    session['username'] = request.args.get('name')
    return res


if __name__ == '__main__':
    # 使用run方法启动后端服务
    app.run(port=8000, debug=True)
